#include "../include/gui/alarmshow.h"
#include "include/gui/ui_data.h"
#include "ui_alarmshow.h"

AlarmShow::AlarmShow(QWidget *parent) :
  QWidget(parent),
  ui(new Ui::AlarmShow)
{
  ui->setupUi(this);
}

AlarmShow::~AlarmShow()
{
  delete ui;
}

void AlarmShow::AlarmShowInit(int alarmstatus)
{
  QString word_str;
  QFont font;
  QPalette color;

  if(alarmstatus == 1)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("防撞条警报");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("将障碍物移开，打开急停即可！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 2)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("电机1通讯警报");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("请检查电机1通讯线路，检查完毕重启机器人！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 3)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("电机2通讯警报");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("请检查电机2通讯线路，检查完毕重启机器人！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 4)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("电机3通讯警报");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("请检查电机3通讯线路，检查完毕重启机器人！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 5)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("电机4通讯警报");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("请检查电机4通讯线路，检查完毕重启机器人！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 6)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("电机5通讯警报");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("请检查电机5通讯线路，检查完毕重启机器人！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 7)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("陀螺仪通讯警报");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("请检查陀螺仪通讯线路，检查完毕重启机器人！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 8)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("IO模块通讯状态");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("请检查IO模块通讯线路，检查完毕重启机器人！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 9)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("电池通讯状态");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("请检查I电池通讯线路，检查完毕重启机器人！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 10)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("交通管制警报");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("将其中一辆车遥控移开即可！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 11)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("障碍检测警报");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("将障碍物移开，打开急停即可！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 12)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("二维码检测警报");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("二维码识别错误，请查看二维码！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 13)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("旋转障碍物检测警报");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("将障碍物移开，打开急停即可！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 14)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("网络连接警报");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("请查看网络连接，重启机器人！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 15)
  {
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("弗洛伊德规划警报");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("弗洛伊德规划警报,机器人重新规划路径！");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);
  }

  if(alarmstatus == 16)
  {
      alarm = 16;
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("装货完成");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::white);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("请确定是否已经装货完成!!!");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);

      ui->Cancel->setGeometry(300,630,120,50);
      ui->sure->setGeometry(835, 630, 120, 50);
  }

  if(alarmstatus == 17)
  {
      alarm = 17;
      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmtext->setFont(font);
      word_str = QString::fromLocal8Bit("卸货完成");
      ui->alarmtext->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::white);
      ui->alarmtext->setPalette(color);

      font.setPointSize(WARNING_WORD_SIZE);
      ui->alarmdealwith->setFont(font);
      word_str = QString::fromLocal8Bit("请确定是否已经卸货完成!!!");
      ui->alarmdealwith->setText(QString(word_str));                //显示页数
      color.setColor(QPalette::WindowText,Qt::red);
      ui->alarmdealwith->setPalette(color);

      ui->Cancel->setGeometry(300,630,120,50);
      ui->sure->setGeometry(835, 630, 120, 50);
  }

  this->show();
  this->showMaximized();}

void AlarmShow::on_sure_clicked()
{
  if(alarm == 16)
  {
      SureCancelStatus = 1;
  }
  else if(alarm == 17)
  {
      SureCancelStatus = 1;
  }

  alarm = 0;
  this->hide();
}

void AlarmShow::on_Cancel_clicked()
{
  alarm = 0;
//  SureCancelStatus = 0;
  this->hide();
}

